import {IEvent, IEventHandle} from './EventM';
import {TokenM} from '../../modules/LoginMs';
import {AppTokenTaskService} from '../app-token-task.service';
import {Injectable} from '@angular/core';


@Injectable({
  providedIn: 'root'
})
export class LoginSuccessEventHandle implements IEventHandle<LoginSuccessEvent> {
  constructor(private appTaskServer: AppTokenTaskService) {
  }

  handle(loginSuccessEvent: LoginSuccessEvent): void {
    console.log("LoginSuccessEventHandle>>>>>", loginSuccessEvent);

    this.appTaskServer.startRefreshTokenTask();
    //throw new Error('Method not implemented.');
  }
}


export class LoginSuccessEvent implements IEvent {
  eventType: string = this.constructor.name;
  data: TokenM[]; // 这里的data可以进一步定义类型

  constructor(data: TokenM[]) {
    //console.log("LoginSuccessEvent>>>>>>>", this.constructor.name);
    this.data = data
  }

}
